package General;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principa.java
 *
 * Created on 14/06/2009, 01:05:08 PM
 */

/**
 *
 * @author GAMA
 */
import javax.swing.JPanel;
import Mantenimiento.Mantenimiento_proveedores;
import Compras.Reporte_compras_productos;
import Seguridad.Mantenimiento_usuarios;
import Ventas.Reporte_ventas_productos;
import Ventas.Reporte_compra_venta;
import Auditoria.Reporte_auditoria_por_fecha;
import Auditoria.Reporte_auditoria_por_usuario;
import Compras.ProductosxProveedor;
import Compras.GastosxProveedor;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.jgoodies.looks.windows.*;
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import Control.Conexion;
import java.io.File;
import java.awt.Desktop;
import javax.swing.JFileChooser;
import Control.ChoosableFileFilter;
import Sistema.PorcentajeIGV;

public class Administrador extends javax.swing.JFrame {
JPanel pnlProveedores;
JPanel pnlReporte_compras;
JPanel pnlReporte_ventas;
JPanel pnlReporte_compra_venta;
JPanel pnlUsuarios;
JPanel pnlProductosxProveedor;
JPanel pnlGastosxProveedor;
JPanel pnlReporte_auditoria_por_fecha;
JPanel pnlReporte_auditoria_por_usuario;
//JPanel pnlSistema;
Validar_Sistema frmValidar;
Acerca_de about;
boolean ingresado=false;
JFileChooser guardar, abrir;
ChoosableFileFilter newChoosableFileFilter=new ChoosableFileFilter();
String datos_generales_usuario="";
Integer codigo_usuario_auditoria=0;
PorcentajeIGV configuracionIGV;

    /** Creates new form Principa */
    public Administrador(Validar_Sistema frmValidar, String datos_usuario, Integer codigo_usuario) {
        initComponents();
        datos_generales_usuario=datos_usuario;
        codigo_usuario_auditoria=codigo_usuario;
        lblDatosUsuario.setText(datos_generales_usuario);
        this.frmValidar=frmValidar;
        this.setTitle("Administrador");        
        Mantenimiento_proveedores Proveedores= new  Mantenimiento_proveedores(this,codigo_usuario);
        Reporte_compras_productos reporte_compras =new Reporte_compras_productos();
        Mantenimiento_usuarios mantenim_usuarios=new Mantenimiento_usuarios(this,codigo_usuario);
        Reporte_ventas_productos reporte_ventas=new Reporte_ventas_productos();
        Reporte_compra_venta reporte_c_v=new Reporte_compra_venta();
        Reporte_auditoria_por_fecha reporte_auditoria_por_fecha=new Reporte_auditoria_por_fecha();
        Reporte_auditoria_por_usuario reporte_auditoria_por_usuario=new Reporte_auditoria_por_usuario();
        ProductosxProveedor prodxproveedor=new ProductosxProveedor();
        GastosxProveedor gastxproveedor= new GastosxProveedor();
        
        pnlProveedores=Proveedores;
        pnlReporte_compras= reporte_compras;
        pnlUsuarios=mantenim_usuarios;
        pnlReporte_ventas=reporte_ventas;
        pnlProductosxProveedor=prodxproveedor;
        pnlGastosxProveedor=gastxproveedor;
        pnlReporte_compra_venta =reporte_c_v;
        pnlReporte_auditoria_por_fecha=reporte_auditoria_por_fecha;
        pnlReporte_auditoria_por_usuario=reporte_auditoria_por_usuario;
        ingresado=true;
        guardar= new JFileChooser();
        abrir= new JFileChooser();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        d = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jButton9 = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        btnCopiaSeguridad = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        btnPorcentajeIGV = new javax.swing.JButton();
        pnlContenedor = new javax.swing.JPanel();
        lblDatosUsuario = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setIconImage(new ImageIcon(this.getClass().getResource("/imagenes/icono.gif")).getImage());

        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jPanel1.setLayout(null);

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mantenimiento de Usuarios", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel8.setLayout(null);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Usuario32.gif"))); // NOI18N
        jButton1.setMnemonic('U');
        jButton1.setText("Usuarios");
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setMaximumSize(new java.awt.Dimension(73, 50));
        jButton1.setMinimumSize(new java.awt.Dimension(73, 50));
        jButton1.setPreferredSize(new java.awt.Dimension(73, 50));
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel8.add(jButton1);
        jButton1.setBounds(20, 10, 120, 80);

        jPanel1.add(jPanel8);
        jPanel8.setBounds(-2, 0, 160, 121);

        jTabbedPane1.addTab("Seguridad", jPanel1);

        jPanel2.setLayout(null);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mantenimiento de Proveedores", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel5.setLayout(null);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Proveedor32.gif"))); // NOI18N
        jButton2.setMnemonic('P');
        jButton2.setText("Proveedores");
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setMaximumSize(new java.awt.Dimension(93, 50));
        jButton2.setMinimumSize(new java.awt.Dimension(93, 50));
        jButton2.setPreferredSize(new java.awt.Dimension(93, 50));
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton2);
        jButton2.setBounds(20, 10, 130, 80);

        jPanel2.add(jPanel5);
        jPanel5.setBounds(-3, 0, 170, 120);

        jTabbedPane1.addTab("Mantenimiento", jPanel2);

        jPanel3.setLayout(null);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Reportes de Compras", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel6.setLayout(null);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Reporte32.gif"))); // NOI18N
        jButton4.setMnemonic('c');
        jButton4.setText("Reporte de compras");
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton4);
        jButton4.setBounds(20, 10, 130, 80);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/stock32.gif"))); // NOI18N
        jButton3.setMnemonic('i');
        jButton3.setText("Informe de stock");
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton3);
        jButton3.setBounds(170, 10, 130, 80);

        d.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Productosxproveedor32_1.gif"))); // NOI18N
        d.setMnemonic('r');
        d.setText("Productos por proveedor");
        d.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        d.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        d.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dActionPerformed(evt);
            }
        });
        jPanel6.add(d);
        d.setBounds(320, 10, 152, 80);

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Montoxproveedor.gif"))); // NOI18N
        jButton8.setMnemonic('G');
        jButton8.setText("Gastos por proveedor");
        jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton8);
        jButton8.setBounds(500, 10, 152, 80);

        jPanel3.add(jPanel6);
        jPanel6.setBounds(0, 0, 670, 120);

        jTabbedPane1.addTab("Compras", jPanel3);

        jPanel4.setLayout(null);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Reportes de Ventas", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel7.setLayout(null);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Reporte32.gif"))); // NOI18N
        jButton7.setMnemonic('v');
        jButton7.setText("Reporte de ventas");
        jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPanel7.add(jButton7);
        jButton7.setBounds(23, 10, 123, 80);

        jPanel4.add(jPanel7);
        jPanel7.setBounds(0, 0, 170, 120);

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Reporte de Compras y Ventas", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel9.setLayout(null);

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/reporte_compras_ventas.gif"))); // NOI18N
        jButton9.setMnemonic('c');
        jButton9.setText("Reporte de Compras y Ventas");
        jButton9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton9.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPanel9.add(jButton9);
        jButton9.setBounds(20, 10, 177, 80);

        jPanel4.add(jPanel9);
        jPanel9.setBounds(180, 0, 220, 120);

        jTabbedPane1.addTab("Ventas", jPanel4);

        jPanel12.setLayout(null);

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Reporte de Auditoría", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel14.setLayout(null);

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Compras_Ventas.gif"))); // NOI18N
        jButton11.setMnemonic('u');
        jButton11.setText("Reporte de Auditoría por Usuario");
        jButton11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton11.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        jPanel14.add(jButton11);
        jButton11.setBounds(240, 10, 190, 80);

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Compras_Ventas.gif"))); // NOI18N
        jButton12.setMnemonic('f');
        jButton12.setText("Reporte de Auditoría por Fecha");
        jButton12.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton12.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        jPanel14.add(jButton12);
        jButton12.setBounds(20, 10, 190, 80);

        jPanel12.add(jPanel14);
        jPanel14.setBounds(0, 0, 450, 120);

        jTabbedPane1.addTab("Auditoría", jPanel12);

        jPanel10.setLayout(null);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Administración de Base de Datos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel11.setLayout(null);

        btnCopiaSeguridad.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/BD.gif"))); // NOI18N
        btnCopiaSeguridad.setText("Copia de Seguridad");
        btnCopiaSeguridad.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCopiaSeguridad.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCopiaSeguridad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCopiaSeguridadActionPerformed(evt);
            }
        });
        jPanel11.add(btnCopiaSeguridad);
        btnCopiaSeguridad.setBounds(30, 10, 130, 80);

        jPanel10.add(jPanel11);
        jPanel11.setBounds(10, 0, 190, 120);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Configuración de Parámetros", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_BOTTOM));
        jPanel13.setLayout(null);

        btnPorcentajeIGV.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/p_igv.gif"))); // NOI18N
        btnPorcentajeIGV.setText("Porcentaje IGV");
        btnPorcentajeIGV.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPorcentajeIGV.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnPorcentajeIGV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPorcentajeIGVActionPerformed(evt);
            }
        });
        jPanel13.add(btnPorcentajeIGV);
        btnPorcentajeIGV.setBounds(30, 10, 130, 80);

        jPanel10.add(jPanel13);
        jPanel13.setBounds(220, 0, 190, 120);

        jTabbedPane1.addTab("Sistema", jPanel10);

        javax.swing.GroupLayout pnlContenedorLayout = new javax.swing.GroupLayout(pnlContenedor);
        pnlContenedor.setLayout(pnlContenedorLayout);
        pnlContenedorLayout.setHorizontalGroup(
            pnlContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 756, Short.MAX_VALUE)
        );
        pnlContenedorLayout.setVerticalGroup(
            pnlContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 414, Short.MAX_VALUE)
        );

        lblDatosUsuario.setText("jLabel1");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Usuario:");

        jMenu1.setMnemonic('S');
        jMenu1.setText("SisCoIn");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Cerrar sesión");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setText("Salir");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setMnemonic('A');
        jMenu2.setText("Ayuda");

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setText("Contenido");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem4.setText("Acerca de...");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlContenedor, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(lblDatosUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 682, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlContenedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lblDatosUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE))
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-774)/2, (screenSize.height-652)/2, 774, 652);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
                  // TODO add your handling code here:
     cargar_panel_proveedores();
    }//GEN-LAST:event_jButton2ActionPerformed

    public void cargar_panel_proveedores(){
        this.pnlContenedor.removeAll();
        pnlProveedores.setSize(761,400);
        this.pnlContenedor.add(pnlProveedores);
        pnlProveedores.repaint();
        pnlProveedores.setVisible(true);

    }
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        this.pnlContenedor.removeAll();

        this.pnlContenedor.repaint();
        Conexion c=new Conexion();
        c.informe_stock_productos();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
cargar_panel_reporte_compras();
    }//GEN-LAST:event_jButton4ActionPerformed
public void cargar_panel_reporte_compras(){

           this.pnlContenedor.removeAll();
       pnlReporte_compras.repaint();
       this.pnlContenedor.add(pnlReporte_compras);
       pnlReporte_compras.setSize(761,400);
       pnlReporte_compras.setVisible(false);
       pnlReporte_compras.setVisible(true);
}
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
   cargar_panel_usuarios();
    }//GEN-LAST:event_jButton1ActionPerformed

    public void cargar_panel_usuarios(){
         this.pnlContenedor.removeAll();
        pnlUsuarios.setSize(761,400);
        this.pnlContenedor.add(pnlUsuarios);
        pnlUsuarios.repaint();
        pnlUsuarios.setVisible(true);
    }
    private void dActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dActionPerformed
        // TODO add your handling code here:
       
       this.pnlContenedor.removeAll();
       pnlProductosxProveedor.repaint();
       this.pnlContenedor.add(pnlProductosxProveedor);
       pnlProductosxProveedor.setSize(761,400);
       pnlProductosxProveedor.setVisible(false);
       pnlProductosxProveedor.setVisible(true);
}//GEN-LAST:event_dActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
   cargar_panel_reporte_ventas();
    }//GEN-LAST:event_jButton7ActionPerformed

    public void cargar_panel_reporte_ventas(){

       this.pnlContenedor.removeAll();
       pnlReporte_ventas.repaint();
       this.pnlContenedor.add(pnlReporte_ventas);
       pnlReporte_ventas.setSize(761,400);
       pnlReporte_ventas.setVisible(false);
       pnlReporte_ventas.setVisible(true);
    }
    public void cargar_panel_reporte_compra_venta(){

       this.pnlContenedor.removeAll();
       pnlReporte_compra_venta.repaint();
       this.pnlContenedor.add(pnlReporte_compra_venta);
       pnlReporte_compra_venta.setSize(761,400);
       pnlReporte_compra_venta.setVisible(false);
       pnlReporte_compra_venta.setVisible(true);
    }
     public void cargar_panel_reporte_auditoria_por_fecha(){
       this.pnlContenedor.removeAll();
       pnlReporte_auditoria_por_fecha.repaint();
       this.pnlContenedor.add(pnlReporte_auditoria_por_fecha);
       pnlReporte_auditoria_por_fecha.setSize(761,400);
       pnlReporte_auditoria_por_fecha.setVisible(false);
       pnlReporte_auditoria_por_fecha.setVisible(true);
    }
     
     public void cargar_panel_reporte_auditoria_por_usuario(){
       this.pnlContenedor.removeAll();
       pnlReporte_auditoria_por_usuario.repaint();
       this.pnlContenedor.add(pnlReporte_auditoria_por_usuario);
       pnlReporte_auditoria_por_usuario.setSize(761,400);
       pnlReporte_auditoria_por_usuario.setVisible(false);
       pnlReporte_auditoria_por_usuario.setVisible(true);
    }
    public void cargar_panel_sistema(){
        this.pnlContenedor.removeAll();
        pnlContenedor.repaint();
    }
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        cerrar_sesion();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
        about =new Acerca_de();
        about.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
        
        int opc=jTabbedPane1.getSelectedIndex();
        if(ingresado){
        System.out.println("abac;"+jTabbedPane1.getSelectedIndex());
        switch(opc){
            case 0: this.cargar_panel_usuarios();
                    break;
            case 1: this.cargar_panel_proveedores();
                    break;
            case 2: this.cargar_panel_reporte_compras();
                    break;
            case 3: this.cargar_panel_reporte_ventas();
                    break;
            case 4: this.cargar_panel_reporte_auditoria_por_fecha();
                    break;
            case 5: this.cargar_panel_sistema();
                    break;
            default: this.cargar_panel_usuarios();
        }
        }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        //manual de ayuda del administrador
          try{
       File path = new File ("manuales\\manual_administrador.chm");
       Desktop.getDesktop().open(path);
        }catch(Exception e){
       System.out.println("No se puede cargar el archivo de ayuda");
        }

    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void btnCopiaSeguridadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopiaSeguridadActionPerformed
        // TODO add your handling code here:
        copiarBaseDatos();
    }//GEN-LAST:event_btnCopiaSeguridadActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
             this.pnlContenedor.removeAll();
       pnlGastosxProveedor.repaint();
       this.pnlContenedor.add(pnlGastosxProveedor);
       pnlGastosxProveedor.setSize(761,400);
       pnlGastosxProveedor.setVisible(false);
       pnlGastosxProveedor.setVisible(true);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
    cargar_panel_reporte_compra_venta();
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        cargar_panel_reporte_auditoria_por_usuario();
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        cargar_panel_reporte_auditoria_por_fecha();
    }//GEN-LAST:event_jButton12ActionPerformed

    private void btnPorcentajeIGVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPorcentajeIGVActionPerformed
        // TODO add your handling code here:
        configuracionIGV =new PorcentajeIGV(codigo_usuario_auditoria);
        configuracionIGV.setVisible(true);
    }//GEN-LAST:event_btnPorcentajeIGVActionPerformed
public void copiarBaseDatos(){
        try{
            guardar.addChoosableFileFilter(newChoosableFileFilter);
        int returnVal = guardar.showSaveDialog(Administrador.this);
        
            String file="c:\\backup.sql";

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File archivo = guardar.getSelectedFile();
            file=archivo.getAbsolutePath();
            file=file+".sql";
            char com='"';
            //String comilla=Character.toString(com);
       //file=comilla+file+comilla;
            String usuario="root";
            String password="root";
            String dbName="atsiscoin";
            char caracter='>';
            String command = "C:\\Archivos de programa\\VertrigoServ\\Mysql\\bin\\mysqldump.exe --opt -u"+usuario+" -p"+password+" "+dbName+" "+caracter+" "+file;
          //String command = "C:\\Archivos de programa\\MySQL\\MySQL Server 6.0\\bin\\mysqldump.exe --opt -u"+usuario+" -p"+password+" "+dbName+" "+caracter+" "+file;

          //  --opt --password=CLAVE --user=USUARIO BASEDATOS > salidaBackup.sql

            System.out.println(command);
            Process p = Runtime.getRuntime().exec (command);
            JOptionPane.showMessageDialog(this,"El Backup ha sido registrado","Mensaje del Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
            
           }

    catch(Exception e){

      //System.out.println(e.toString()+"");
    JOptionPane.showMessageDialog(this,"El backup no se ha podido registrar","Mensaje del Sistema",1);
    }


}
public void restaurarBaseDatos(){
     try{
            abrir.addChoosableFileFilter(newChoosableFileFilter);
        int returnVal = abrir.showOpenDialog(Administrador.this);
            String file="";
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File archivo = abrir.getSelectedFile();
            file=archivo.getAbsolutePath();
            char com='"';
            String comilla=Character.toString(com);
          file=comilla+file+comilla;
            String usuario="root";
            String password="root";
            String dbName="backupsiscoin";
            //String[] executeCmd = new String[]{"mysql", dbName, "- -user=" + usuario, "--password=" + password, "-e", " source "+file};
            String command = "C:\\Archivos de programa\\MySQL\\MySQL Server 6.0\\bin\\mysql backupsiscoin -u"+usuario+" -p"+password+" -e"+file;
            Process runtimeProcess = Runtime.getRuntime().exec(command);
            System.out.println(command);
            //Process runtimeProcess =             Runtime.getRuntime().exec(executeCmd);
            //int processComplete = runtimeProcess.waitFor();
            JOptionPane.showMessageDialog(this,"Se ha restaurado correctamente","Mensaje del Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
           }

    catch(Exception e){
    JOptionPane.showMessageDialog(this,"El backup no se ha podido registrar","Mensaje del Sistema",1);
    }
}
    public void cerrar_sesion(){
     int rpta=msgmarticuloConfirmacion("¿Esta seguro que desea cerrar sesión?");
                if(rpta==0)
                { this.setVisible(false);
                  this.frmValidar.limpiar_campos();
                  this.frmValidar.setVisible(true);
                }
}

    public int  msgmarticuloConfirmacion(String msg){
        Object[] opciones = {"Si", "No","Cancelar"};
        int n = JOptionPane.showOptionDialog(this,
                                    msg,
                                    "Información",
                                    JOptionPane.YES_NO_OPTION,
                                    JOptionPane.QUESTION_MESSAGE,
                                    null,
                                    opciones,
                                    opciones[2]);
       return n;
    }
    public JPanel getPanelContenedor(){
    return pnlContenedor;
}
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
               try {
           UIManager.setLookAndFeel(new WindowsLookAndFeel());
            
            //new Administrador().setVisible(true);
       } catch (UnsupportedLookAndFeelException ex) {
          ex.printStackTrace();
       }
           }

        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCopiaSeguridad;
    private javax.swing.JButton btnPorcentajeIGV;
    private javax.swing.JButton d;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblDatosUsuario;
    private javax.swing.JPanel pnlContenedor;
    // End of variables declaration//GEN-END:variables

}
